package com.web.model;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Record;
import com.web.controller.LoginController;

/**
 * 功能：用户表的模型层
 * 
 * @author chenxm
 *
 */
public class User extends Model<User> {

	private final Log log = LogFactory.getLog(User.class);

	public static final User dao = new User();

	/**
	 * 功能：通过用户名查询用户密码
	 * 
	 * @param username
	 * @return String
	 */
	public String getPwdByName(String username) {
		Record result = Db
				.findFirst("select password from user where username = '"
						+ username + "'");
		return result == null ? "" : result.getStr("password");
	}
	
	public String getUserByEmail(String email)
	{
		Record result = Db
				.findFirst("select username from user where email = '"
						+ email + "'");
		return result == null ? "" : result.getStr("username");
	}

}
